home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / grep.z / grep
Text File  |  1998-10-20  |  15KB  |  331 lines

  1.  
  2.  
  3.  
  4. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _gggg_rrrr_eeee_pppp - search a file for a pattern
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _gggg_rrrr_eeee_pppp [_----_EEEE| _----_FFFF] [_----_cccc| _----_llll| _----_qqqq] [_----_iiii_nnnn_ssss_vvvv_xxxx] _----_eeee _p_a_t_t_e_r_n__l_i_s_t[_----_ffff _p_a_t_t_e_r_n__f_i_l_e]. .
  13.      .[_f_i_l_e . . .]
  14.  
  15.      _gggg_rrrr_eeee_pppp [_----_EEEE| _----_FFFF] [_----_cccc| _----_llll| _----_qqqq] [_----_iiii_nnnn_ssss_vvvv_xxxx][_----_eeee _p_a_t_t_e_r_n__l_i_s_t_----_ffff _p_a_t_t_e_r_n__f_i_l_e]. .
  16.      .[_f_i_l_e . . .]
  17.  
  18.      _gggg_rrrr_eeee_pppp [_----_EEEE| _----_FFFF] [_----_cccc| _----_llll| _----_qqqq] [_----_iiii_nnnn_ssss_vvvv_xxxx] _p_a_t_t_e_r_n__l_i_s_t[_f_i_l_e . . .]
  19.  
  20. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.      The _g_r_e_p utility searches the input files, selecting lines matching one
  22.      or more patterns; the types of patterns are controlled by the options
  23.      specified.  The patterns are specified by the _----_eeee option, _----_ffff option, or
  24.      the _p_a_t_t_e_r_n__l_i_s_t operand. The _p_a_t_t_e_r_n__l_i_s_t's value consists of one or
  25.      more patterns separated by newline characters; the _p_a_t_t_e_r_n__f_i_l_e's
  26.      contents consist of one or more patterns terminated by newline
  27.      characters.  By default, an input line will be selected if any pattern,
  28.      treated as an entire basic regular expression (BRE) as described in the
  29.      _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled: _B_a_s_i_c _R_e_g_u_l_a_r _E_x_p_r_e_s_s_i_o_n_s,
  30.      matches any part of the line; a null BRE will match every line. By
  31.      default, each selected input line will be written to the standard output.
  32.  
  33.      Regular expression matching will be based on text lines.  Since a newline
  34.      character separates or terminates patterns (see the _----_eeee and _----_ffff options
  35.      below), regular expressions cannot contain a newline character.
  36.      Similarly, since patterns are matched against individual lines of the
  37.      input, there is no way for a pattern to match a newline character found
  38.      in the input.
  39.  
  40.      Command line options are:
  41.  
  42.  
  43.      _----_EEEE      Match using extended regular expressions. Treat each pattern
  44.              specified as an ERE, as described in the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page
  45.              under the section titled:  _E_x_t_e_n_d_e_d _R_e_g_u_l_a_r _E_x_p_r_e_s_s_i_o_n_s.  If any
  46.              entire ERE pattern matches an input line, the line will be
  47.              matched. A null ERE matches every line.
  48.  
  49.      _----_FFFF      Match using fixed strings.  Treat each pattern specified as a
  50.              string instead of a regular expression. If an input line contains
  51.              any of the patterns as a contiguous sequence of bytes, the line
  52.              will be matched. A null string matches every line.
  53.  
  54.      _----_cccc      Write only a count of selected lines to standard output.
  55.  
  56.      _----_eeee _p_a_t_t_e_r_n__l_i_s_t
  57.              Specify one or more patterns to be used during the search for
  58.              input. Patterns in _p_a_t_t_e_r_n__l_i_s_t must be separated by a newline
  59.              character.  A null pattern can be specified by two adjacent
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  71.  
  72.  
  73.  
  74.              newline characters in _p_a_t_t_e_r_n__l_i_s_t. Unless the _----_EEEE or _----_FFFF option is
  75.              also specified, each pattern will be treated as a BRE, as
  76.              described in the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled:
  77.              _B_a_s_i_c _R_e_g_u_l_a_r _E_x_p_r_e_s_s_i_o_n_s. Multiple _----_eeee and _----_ffff options are
  78.              accepted by the _g_r_e_p utility.  All of the specified patterns are
  79.              used when matching lines, but the order of evaluation is
  80.              unspecified.
  81.  
  82.      _----_ffff _p_a_t_t_e_r_n__f_i_l_e
  83.              Read one or more patterns from the file named by the pathname
  84.              pattern_file.  Patterns in _p_a_t_t_e_r_n__f_i_l_e are terminated by a
  85.              newline character.  A null pattern can be specified by an empty
  86.              line in _p_a_t_t_e_r_n__f_i_l_e.  Unless the _----_EEEE or _----_FFFF option is also
  87.              specified, each pattern will be treated as a BRE, as described in
  88.              the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled: _B_a_s_i_c _R_e_g_u_l_a_r
  89.              _E_x_p_r_e_s_s_i_o_n_s.
  90.  
  91.      _----_iiii      Perform pattern matching in searches without regard to case. See
  92.              the _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5) man page under the section titled: _R_e_g_u_l_a_r
  93.              _E_x_p_r_e_s_s_i_o_n _G_e_n_e_r_a_l _R_e_q_u_i_r_e_m_e_n_t_s.
  94.  
  95.      _----_llll      Write only the names of files containing selected lines to
  96.              standard output.  Pathnames are written once per file searched.
  97.              If the standard input is searched, a pathname of "(_ssss_tttt_aaaa_nnnn_dddd_aaaa_rrrr_dddd
  98.              _iiii_nnnn_pppp_uuuu_tttt)" will be written, in the POSIX locale.  In other locales,
  99.              _ssss_tttt_aaaa_nnnn_dddd_aaaa_rrrr_dddd _iiii_nnnn_pppp_uuuu_tttt may be replaced by something more appropriate in
  100.              those locales.
  101.  
  102.      _----_nnnn      Precede each output line by its relative line number in the file,
  103.              each file starting at line 1. The line number counter will be
  104.              reset for each file processed.
  105.  
  106.      _----_qqqq      Quiet.  Do not write anything to the standard output, regardless
  107.              of matching lines. Exit with zero status if an input line is
  108.              selected.
  109.  
  110.      _----_ssss      Suppress the error messages ordinarily written for non-existent
  111.              or unreadable files. Other error messages will not be suppressed.
  112.  
  113.      _----_vvvv      Select lines not matching any of the specified patterns.  If the
  114.              _----_vvvv option is not specified, selected lines will be those that
  115.              match any of the specified patterns.
  116.  
  117.      _----_xxxx      Consider only input lines that use all characters in the line to
  118.              match an entire fixed string or regular expression to be matching
  119.              lines.
  120.  
  121.  
  122. OOOOPPPPEEEERRRRAAAANNNNDDDDSSSS
  123.      The following operands are supported:
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  137.  
  138.  
  139.  
  140.      _p_a_t_t_e_r_n
  141.           Specify one or more patterns to be used during the search for input.
  142.           This operand is treated as if it were specified as _----_eeee _p_a_t_t_e_r_n__l_i_s_t.
  143.  
  144.      _f_i_l_e A pathname of a file to be searched for the patterns.  If no _f_i_l_e
  145.           operands are specified, the standard input will be used.
  146.  
  147. SSSSTTTTDDDDIIIINNNN
  148.      The standard input will be used only if no _f_i_l_e operands are specified.
  149.      See _IIII_NNNN_PPPP_UUUU_TTTT _FFFF_IIII_LLLL_EEEE_SSSS.
  150.  
  151. IIIINNNNPPPPUUUUTTTT FFFFIIIILLLLEEEESSSS
  152.      The input files must be text files.
  153.  
  154. SSSSTTTTDDDDOOOOUUUUTTTT
  155.      If the _----_llll option is in effect, and the _----_qqqq option is not, the following
  156.      will be written for each file containing at least one selected input
  157.      line:
  158.  
  159.           "%s\n", _f_i_l_e
  160.  
  161.      Otherwise, if more than one _f_i_l_e argument appears, and _----_qqqq is not
  162.      specified, the _g_r_e_p utility will prefix each output line by:
  163.  
  164.           "%s:", _f_i_l_e
  165.  
  166.      The remainder of each output line depends on the other options specified:
  167.  
  168.  
  169.      _oooo  If the _----_cccc option is in effect, the remainder of each output line will
  170.         contain:
  171.  
  172.              "%d\n", <_c_o_u_n_t>
  173.  
  174.  
  175.      _oooo  Otherwise, if _----_cccc is not in effect and the _----_nnnn option is in effect, the
  176.         following will be written to standard output:
  177.  
  178.              "%d:", <_l_i_n_e _n_u_m_b_e_r>
  179.  
  180.  
  181.      _oooo  Finally, the following will be written to standard output:
  182.  
  183.              "%s", <_s_e_l_e_c_t_e_d-_l_i_n_e _c_o_n_t_e_n_t_s>
  184.  
  185.  
  186. SSSSTTTTDDDDEEEERRRRRRRR
  187.      Used only for diagnostic messages.
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  203.  
  204.  
  205.  
  206. SEE ALSO
  207.      _eeee_dddd(1), _eeee_gggg_rrrr_eeee_pppp(1), _ffff_gggg_rrrr_eeee_pppp(1), _rrrr_eeee_gggg_cccc_oooo_mmmm_pppp(5), _ssss_eeee_dddd(1), _ssss_hhhh(1)
  208.  
  209. EEEEXXXXIIIITTTT SSSSTTTTAAAATTTTUUUUSSSS
  210.      Exit status is 0 if any matches are found, 1 if none, >1 for syntax
  211.      errors or inaccessible files (even if matches were found).
  212.  
  213. CCCCOOOONNNNSSSSEEEEQQQQUUUUEEEENNNNCCCCEEEESSSS OOOOFFFF EEEERRRRRRRROOOORRRRSSSS
  214.      If the _----_qqqq option is specified, the exit status will be zero if an input
  215.      line is selected, even if an error was detected.
  216.  
  217.      If the requested action cannot be performed on a file, _gggg_rrrr_eeee_pppp will issue a
  218.      diagnostic message to standard error and continue processing the next
  219.      operand in sequence, but the final exit status is returned as non-zero.
  220.  
  221. AAAAPPPPPPPPLLLLIIIICCCCAAAATTTTIIIIOOOONNNN UUUUSSSSAAAAGGGGEEEE
  222.      Care should be taken when using characters in _p_a_t_t_e_r_n__l_i_s_t that may also
  223.      be meaningful to the command interpreter. It is safest to enclose the
  224.      entire _p_a_t_t_e_r_n__l_i_s_t argument in single quotes:
  225.  
  226.  
  227.      The _----_eeee _p_a_t_t_e_r_n__l_i_s_t option has the same effect as the _p_a_t_t_e_r_n__l_i_s_t
  228.      operand, but is useful when _p_a_t_t_e_r_n__l_i_s_t begins with the hyphen
  229.      delimiter. It is also useful when it is more convenient to provide
  230.      multiple patterns as separate arguments.
  231.  
  232.      Multiple _----_eeee and _----_ffff options are accepted and _g_r_e_p will use all of the
  233.      patterns it is given while matching input text lines. (Note that the
  234.      order of evaluation is not specified. If an implementation finds a null
  235.      string as a pattern, it is allowed to use that pattern first, matching
  236.      every line, and effectively ignore any other patterns.)
  237.  
  238.      The _----_qqqq option provides a means of easily determining whether or not a
  239.      pattern (or string) exists in a group of files.  When searching several
  240.      files, it provides a performance improvement (because it can quit as soon
  241.      as it finds the first match) and requires less care by the user in
  242.      choosing the set of files to supply as arguments (because it will exit
  243.      zero if it finds a match even if _g_r_e_p detected an access or read error on
  244.      earlier file operands).
  245.  
  246. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  247.      1.   To find all uses of the word Posix in a bunch of files where some of
  248.           the files cannot be opened due to permission restrictions:
  249.  
  250.                _g_r_e_p -_q -_n _P_o_s_i_x /_e_t_c/*
  251.  
  252.           Note the above use of the -_q command line option to _g_r_e_p.  If the -_q
  253.           is not used in the above command line, then when the first file is
  254.           encountered that is not readable _g_r_e_p will error terminate even if
  255.           there were some matches found.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. GGGGRRRREEEEPPPP((((1111))))                                                                GGGGRRRREEEEPPPP((((1111))))
  269.  
  270.  
  271.  
  272.      2.   To find all uses of the word Posix (in any case) in file _tttt_eeee_xxxx_tttt_...._mmmm_mmmm and
  273.           write with line numbers:
  274.  
  275.                _g_r_e_p -_i -_n _p_o_s_i_x _t_e_x_t._m_m
  276.  
  277.  
  278.      3.   To find all empty lines in the standard input:
  279.  
  280.                _g_r_e_p $
  281.                or:
  282.                _g_r_e_p -_v
  283.  
  284.  
  285.      4.   Both of the following commands print all lines containing strings
  286.           _aaaa_bbbb_cccc or _dddd_eeee_ffff or both:
  287.  
  288.                _g_r_e_p -_E '_a_b_c
  289.                _d_e_f'
  290.                _g_r_e_p -_F '_a_b_c
  291.                _d_e_f'
  292.  
  293.  
  294.      5.   Both of the following commands print all lines matching exactly _aaaa_bbbb_cccc
  295.           or _dddd_eeee_ffff:
  296.  
  297.                _g_r_e_p -_E '_a_b_c$
  298.                ^_d_e_f$'
  299.                _g_r_e_p -_F -_x '_a_b_c
  300.                _d_e_f'
  301.  
  302.  
  303. BBBBUUUUGGGGSSSS
  304.      If there is a line with embedded nulls, _gggg_rrrr_eeee_pppp will only match up to the
  305.      first null; if it matches, it will print the entire line.
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.